﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Controller_Interface
{
    public class LoggInt
    {

        public void LogLevelOne(String messageType, String message)
        {
            String logMessage = GetString(messageType, message);
            OnLogAppeared(new LogAppearedEventArgs(1, logMessage));
        }

        public void LogLevelZero(String messageType, String message)
        {
            String logMessage = GetString(messageType, message);
            OnLogAppeared(new LogAppearedEventArgs(0, logMessage));

        }

        private static String GetString(String messageType, String message)
        {
            var stringBuilder = new StringBuilder();
            stringBuilder.AppendFormat("[{0:hh:mm:ss:fff}] {1} {2}", DateTime.Now, messageType, message);
            return stringBuilder.ToString();
        }


        #region secret

        public event EventHandler<LogAppearedEventArgs> LogAppeared;

        protected virtual void OnLogAppeared(LogAppearedEventArgs e)
        {
            if (LogAppeared != null) LogAppeared(this, e);
        }

        #endregion

    }

    public class LogAppearedEventArgs : EventArgs
    {
        public readonly int Level;
        public readonly String Content;

        public LogAppearedEventArgs(int level, string content)
        {
            Level = level;
            Content = content;
        }
    }

}
